package com.atguigu.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @USER: dayu
 * @DATE: 2020/4/3
 * @DESCRIPTION:
 */
@RestController
@Slf4j
public class PaymentConsumerNacosController {
    @Resource
    RestTemplate restTemplate;

    @Value("${nacos-serever.server-url}")
    private String SERVER_URL;

    @GetMapping("/consumer/payment/get/{id}")
    public String payment(@PathVariable("id") Integer id) {
        String result = restTemplate.getForObject(SERVER_URL+"/payment/get/"+id, String.class);
        System.out.println(result);
        return result;
    }
}
